package site.suimu.controller;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import site.suimu.pojo.TLike;
import site.suimu.service.TLikeService;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping(value = "like")
public class TLikeController {

    @Resource
    TLikeService service;

    @RequestMapping(value = "/create")
    @ResponseBody
    public String create(TLike insDemo){
        if(service.ins(insDemo)){
            return "success";
        }
        return "failed";
    }

    @RequestMapping(value = "/delete")
    @ResponseBody
    public String delete(@RequestParam("id")int id){
        if(service.dle(id)){
            return "success";
        }
        return "failed";
    }

    @RequestMapping(value = "/list")
    @ResponseBody
    public String list(@RequestParam("uId")int uId){
        Map map = new HashMap<String, ArrayList>();
        map.put("list",service.sleByUid(uId));
        return map.toString();
    }

}
